<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<style>
    /*重新设置样式*/
    .form-control {
        width: 196px !important;
        height: 34px !important;
        padding: 10px !important;
    }

    .hidden {
        display: none;
    }

    .items {
        margin: 0;
        list-style: none;
        list-style-position: initial;
        list-style-image: initial;
        list-style-type: none;
        color: #666666 !important;
        font-size: 12px/1.5;
    }

    .items-item {
        display: block;
        float: left;
        margin-right: 25px;
    }

    .items-item span {
        padding: 5px;
        background-color: #E3E3E3;
    }

    .item-remove {
        color: red;
        background-color: transparent;
        outline: none;
        border: none;
        visibility: hidden;
    }

    .item-edit {
        color: #F39C12;
        background-color: transparent;
        outline: none;
        border: none;
        visibility: hidden;
    }
</style>
<body class="hold-transition skin-blue sidebar-mini">


<!--编辑模态框-->
<div class="modal fade" id="modal-select-purchase">
    <div class="modal-dialog" style="width: 640px;">
        <div class="modal-content">
            <div class="modal-header" style="padding-bottom: 0px;">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">库存信息编辑</h4>
            </div>
            <div class="modal-body" style="padding-bottom: 5px;padding-top: 0px;">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="box">
                            <div class="box-header" style="padding-bottom: 0px;"></div>
                            <div class="box-body" style="padding-top: 0px;padding-bottom: 0px;">

                                <form id="editForm" class="form-horizontal">
                                    <div hidden>
                                        <input hidden name="ityIds">
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">项目名称</label>
                                        <div class="col-sm-6">
                                            <input type="text" class="form-control" name="ityProName"
                                                   maxlength="255" disabled="disabled"/>
                                        </div>
                                        <div class="checkbox col-sm-3" style="padding-left: 0px;padding-right: 0px">
                                            <input type="checkbox" onclick="enableInput('ityProName')"
                                                   name="ityProNameIsEnable" title="勾选启用项目名称编辑"/>
                                            勾选启用项目名称编辑
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">仓库</label>
                                        <div class="col-sm-6">
                                            <select type="text" class="form-control select" name="ityWhiId"
                                                    disabled="disabled"
                                                    style="padding: 0px!important;text-align: center!important;text-align-last: center!important;width: auto!important;">
                                            </select>
                                        </div>
                                        <div class="checkbox col-sm-3" style="padding-left: 0px;padding-right: 0px">
                                            <input type="checkbox" onclick="enableInput('ityWhiId')"
                                                   name="ityWhiIdIsEnable" title="勾选启用仓库编辑"/>
                                            勾选启用仓库编辑
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">区位</label>
                                        <div class="col-sm-6">
                                            <input type="text" class="form-control" name="ityPosition"
                                                   maxlength="255" disabled="disabled"/>
                                        </div>
                                        <div class="checkbox col-sm-3" style="padding-left: 0px;padding-right: 0px">
                                            <input type="checkbox" onclick="enableInput('ityPosition')"
                                                   name="ityPositionIsEnable" title="勾选启用区位编辑"/>
                                            勾选启用区位编辑
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">箱号</label>
                                        <div class="col-sm-6">
                                            <input type="text" class="form-control" name="ityCaseNo"
                                                   maxlength="255" disabled="disabled"/>
                                        </div>
                                        <div class="checkbox col-sm-3" style="padding-left: 0px;padding-right: 0px">
                                            <input type="checkbox" onclick="enableInput('ityCaseNo')"
                                                   name="ityCaseNoIsEnable" title="勾选启用箱号编辑"/>
                                            勾选启用箱号编辑
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">记账日期</label>
                                        <div class="col-sm-6">
                                            <input class="form-control  datepicker" type="text" disabled="disabled"
                                                   name="ityBookkeepingDateText" readonly="readonly"
                                                   maxlength="255"/>
                                        </div>
                                        <div class="checkbox col-sm-3" style="padding-left: 0px;padding-right: 0px">
                                            <input type="checkbox" onclick="enableInput('ityBookkeepingDateText')"
                                                   name="ityBookkeepingDateTextIsEnable"
                                                   title="勾选启用记账日期编辑"/>
                                            勾选启用记账日期编辑
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">机械备件库备注类型</label>
                                        <div class="col-sm-6">
                                            <input type="text" class="form-control" name="ityRemarkType" disabled="disabled"
                                                   maxlength="255"/>
                                        </div>
                                        <div class="checkbox col-sm-3" style="padding-left: 0px;padding-right: 0px">
                                            <input type="checkbox" onclick="enableInput('ityRemarkType')"
                                                   name="ityRemarkTypeIsEnable" title="勾选启用机械备件库备注类型编辑"/>
                                            勾选启用机械备件库备注类型编辑
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">备注</label>
                                        <div class="col-sm-6">
                                            <input type="text" class="form-control" name="ityRemark" disabled="disabled"
                                                   maxlength="255"/>
                                        </div>
                                        <div class="checkbox col-sm-3" style="padding-left: 0px;padding-right: 0px">
                                            <input type="checkbox" onclick="enableInput('ityRemark')"
                                                   name="ityRemarkIsEnable" title="勾选启用备注编辑"/>
                                            勾选启用备注编辑
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer" style="padding-top: 5px;">
                <button id="btn-submit" type="button" class="btn btn-success">保存</button>
                <button id="btn-cancel" type="button" class="btn btn-warning" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>

</div>
<!--上传模态框-->
<div class="modal fade" id="modal-file-upload">
    <div class="modal-dialog" style="width: 1000px;">
        <div class="modal-content">
            <div class="modal-header" style="padding-bottom: 0px;">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title col-xs-6" style="display:inline-block">台账管理</h4>
                <h4 class="col-xs-4" style="display:inline-block">文件管理</h4>
            </div>
            <div class="modal-body" style="padding-bottom: 5px;padding-top: 0px;">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="col-xs-6">
                            <div class="box">
                                <div class="box-header" style="padding-bottom: 0px;">
                                    <h3 style="font-size: 16px;font-weight: bold;margin: 0px;display: inline-block">
                                        台账信息</h3>
                                    <button onclick="addLedger()" type="button" class="btn btn-info pull-right">新增
                                    </button>
                                </div>
                                <div class="box-body" style="padding-top: 0px;padding-bottom: 0px;">
                                    <form id="inventoryMaterielInfoForm" class="form-horizontal">
                                        <div hidden>
                                            <input type="hidden" name="ityId"/>
                                        </div>

                                        <div class="row">
                                            <div class="form-inline">
                                                <label class="control-label"
                                                       style="width: 90px;text-align: right">物料描述:</label>
                                                <label class="control-label" name="ityMatDesc"
                                                       style="width: 300px;text-align: left"></label>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="form-inline">
                                                <label class="control-label" style="width: 90px;text-align: right">SAP物料编码:</label>
                                                <label class="control-label" name="itySapCode"
                                                       style="width: 300px;text-align: left"></label>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="form-inline">
                                                <label class="control-label"
                                                       style="width: 90px;text-align: right">数量:</label>
                                                <label class="control-label" name="ityNum"
                                                       style="text-align: left"></label>
                                                <label class="control-label" name="ityNumUnit"
                                                       style="text-align: left"></label>
                                            </div>
                                        </div>
                                        <div class="row"
                                             style="padding: 10px;border: 1px solid #e6e6e6;margin: 10px 0px">
                                            <ul id="items" class="items">
                                                <li name="item" class="items-item">
                                                    <a name="item_title"></a>
                                                    AAA:BBB
                                                    <a name="item_value"></a>
                                                    <button name="item_remove" class="item-remove">
                                                        <i class="glyphicon glyphicon-remove"></i>
                                                    </button>
                                                </li>

                                            </ul>

                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-6">
                            <form id="uploadForm">
                                <div class="box">
                                    <div class="box-header" style="padding-bottom: 0px;">
                                        <input name="anxItyId" type="hidden">
                                    </div>
                                    <div class="box-body" style="padding-top: 0px;padding-bottom: 0px;">
                                        <div class="row">
                                            <div hidden>
                                                <input type="hidden" name="ityId">
                                            </div>
                                            <div class="row">
                                                <div class="form-inline">
                                                    <div class="form-group pull-left">
                                                        <form method="post" class="form-horizontal pull-left"
                                                              enctype="multipart/form-data"
                                                              style="display: inline-block">
                                                            <input id="anxItyId" type="hidden"/>
                                                            <input id="uploadFile" name="file" type="file"/>
                                                            <input id="anxUploadIp" name="anxUploadIp"
                                                                   th:value="${anxUploadIp}" type="hidden"/>
                                                        </form>
                                                    </div>
                                                    <div class="form-group pull-right">
                                                        <button shiro:hasAnyPermissions="purinv:purinvedit:upload"
                                                                id="btn-upload" type="button"
                                                                class="btn btn-success pull-left">上传
                                                        </button>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <table id="anxTable" class="table table-bordered " width="100%">
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>

                </div>
            </div>
            <div class="modal-footer" style="padding-top: 5px;">
                <button id="btn-close" type="button" class="btn btn-default pull-right" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>

</div>
<!--编辑模态框-->
<div class="modal fade" id="modal-addLedger">
    <div class="modal-dialog" style="width: 500px; height: 600px">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">台账信息编辑</h4>
            </div>
            <form id="ledgerForm" class="form-horizontal" role="form" style="margin-right: 70px">
                <div class="modal-body">
                    <input type="hidden" id="imiItyId" name="imiItyId">
                    <input type="hidden" id="imiId" name="imiId">
                    <div class="form-group">
                        <label class="col-sm-4 control-label no-padding-right" for="imiField">字段名</label>
                        <div class="col-sm-8">
                            <input type="text" id="imiField" name="imiField"
                                   class="form-control">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label no-padding-right" for="imiValue">值</label>
                        <div class="col-sm-8">
                            <input type="text" id="imiValue" name="imiValue" maxlength="10"
                                   oninput="xyh.inputDecimalThree(this)"
                                   class="form-control">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label no-padding-right" for="imiUnit">台账单位</label>
                        <div class="col-sm-8">
                            <input type="text" id="imiUnit" name="imiUnit"
                                   class="form-control">
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-info file-contract btn-file" id="btn-ledger-commit">保存</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                </div>
            </form>
        </div>
    </div>
</div>
<section class="content-header">
    <h1>库存信息编辑</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm">
                        <div class="row" id="HiddenDiv">
                            <div class="form-inline">
                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px;">
                                    <label>项目编号</label>
                                    <input type="text" id="ityProCode" name="ityProCode"
                                           class="form-control"
                                           placeholder="请输入项目编号">
                                </div>
                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px;">
                                    <label>项目名称</label>
                                    <input type="text" id="ityProName" name="ityProName"
                                           class="form-control"
                                           placeholder="请输入项目名称">
                                </div>

                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px;">
                                    <label>
                                        物料描述
                                    </label>
                                    <input type="text" id="ityMatDesc" name="ityMatDesc"
                                           class="form-control"
                                           placeholder="请输入物料描述">
                                </div>
                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px;">
                                    <label>
                                        SAP物料编码
                                    </label>
                                    <input type="text" id="itySapCode" name="itySapCode"
                                           class="form-control"
                                           placeholder="请输入SAP物料编码">
                                </div>
                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px;">
                                    <label>跟踪号</label>
                                    <input type="text" id="ityTrackCode" name="ityTrackCode"
                                           class="form-control"
                                           placeholder="请输入跟踪号">
                                </div>

                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px;">
                                    <label>仓库</label>
                                    <select id="ityWhiId" class="form-control select" name="ityWhiId"
                                            style="padding: 0px!important;text-align: center!important;text-align-last: center!important;width:autopx!important">
                                    </select>
                                    <!--<input type="text" id="stockMaterialTypeQuery" name="stockMaterialTypeQuery"
                                           class="form-control"
                                           placeholder="请输入原料类型">-->
                                </div>
                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px;">
                                    <label>
                                        区位
                                    </label>
                                    <input type="text" id="ityPosition" name="ityPosition"
                                           class="form-control"
                                           placeholder="请输入区位">
                                </div>
                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px;">
                                    <label>
                                        箱号
                                    </label>
                                    <input type="text" id="ityCaseNo" name="ityCaseNo"
                                           class="form-control"
                                           placeholder="请输入箱号">
                                </div>
                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px;">
                                    <label>
                                        生产状态
                                    </label>
                                    <select id="proProductionStatus" name="proProductionStatus"
                                            class="form-control select"
                                            style="padding: 0px!important;text-align: center!important;text-align-last: center!important;width:80px!important;width: 80px!important;">
                                        <option value="" selected="selected">全部</option>
                                        <option value="-1">无状态</option>
                                        <option value="1">未开始</option>
                                        <option value="2">执行中</option>
                                        <option value="3">已完成</option>
                                        <option value="4">取消</option>
                                        <option value="5">暂缓</option>
                                    </select>
                                </div>
                                <div class="form-group" style="margin-right: 10px; margin-bottom: 5px">
                                    <label>在库类型</label>
                                    <select name="ityStockType" class="form-control"
                                            style="padding: 0px!important;text-align: center!important;text-align-last: center!important;width:80px!important;">
                                        <option selected="selected" value="">全部</option>
                                        <option value="1">库存在库</option>
                                        <option value="2">项目在库</option>
                                    </select>
                                </div>
                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px;">
                                    <button type="button" class="btn btn-success" id="btn_inventorySearch">搜索</button>

                                </div>

                            </div>
                        </div>
                    </form>
                </div>
                <!--<div class="row" id="toolbar">-->
                <div class="row" id="toolbar">
                    <button shiro:hasPermission="purinv:purinvedit:edit" type="button"
                            class="btn btn-warning" id="btn-editItems">批量修改
                    </button>
                    <a class="btn btn-info" shiro:hasAnyPermissions="purinv:purledgerview:view"
                       href="/pInventoryInfoEdit/gotoSeeLedger">台账查询</a>
                </div>
                <div class="box-body">
                    <div class="table-responsive" style="z-index: 1;">
                        <table id="inventoryQueryTable" class="table table-bordered " width="100%">
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

<div th:include="include :: footer"></div>

<script th:inline="javascript">
    var bTable;

    /**
     *@FunctionName: enableInput
     *@Description: 启用编辑项
     *@DesignIdea: 启用编辑项
     *@Author: 徐一贺
     *@CreateDate: 2020/6/23 10:20
     *@Phone: 18241927380
     *@Param:
     *@Return:
     *@Throw:
     *@Version: v 1.0.0
     */
    function enableInput(controlId) {
        if ($("#editForm [name='" + controlId + "IsEnable']").prop('checked')) {
            $("#editForm [name='" + controlId + "']").removeAttr("disabled");
            if (controlId == "ityBookkeepingDateText") {
                $("#editForm [name='" + controlId + "']").css("background", "#ffffff");
            }
        } else {
            $("#editForm [name='" + controlId + "']").attr("disabled", "disabled");
            if (controlId == "ityBookkeepingDateText") {
                $("#editForm [name='" + controlId + "']").css("background", "#eeeeee");
            }
        }

    }

    /**
     *@FunctionName: openEditPanel
     *@Description: 打开编辑面板
     *@DesignIdea: 打开编辑面板，判断[ids]参数是否是多选产生，如果不是多选产生则回显编辑数据，否则不回显编辑数据。
     *@Author: 徐一贺
     *@CreateDate: 2020/5/9 16:10
     *@Phone: 18241927380
     *@Param: [ids] 库存主键们
     *@Version: v 1.0.0
     */
    function openEditPanel(ids) {
        $("#editForm")[0].reset();
        $("#editForm input[name='ityIds']").val(ids);
        if (ids.toString().indexOf(',') < 0) {
            var rowData = $("#inventoryQueryTable").bootstrapTable('getRowByUniqueId', ids);
            $("#editForm input[name='ityProName']").val(rowData.ityProName);
            $("#editForm input[name='ityPosition']").val(rowData.ityPosition);
            $("#editForm input[name='ityRemark']").val(rowData.ityRemark);
            $("#editForm input[name='ityRemarkType']").val(rowData.ityRemarkType);
            $("#editForm [name='ityWhiId']").val(rowData.ityWhiId);
            $("#editForm [name='ityCaseNo']").val(rowData.ityCaseNo);
            $("#editForm input[name='ityBookkeepingDateText']").val(rowData.ityBookkeepingDate);
        } else {
            $("#editForm input[name='ityProName']").val("");
            $("#editForm input[name='ityPosition']").val("");
            $("#editForm input[name='ityRemark']").val("");
            $("#editForm input[name='ityRemarkType']").val("");
            $("#editForm [name='ityCaseNo']").val("");
        }
        $("#editForm [name='ityProName']").attr("disabled", "disabled");
        $("#editForm [name='ityPosition']").attr("disabled", "disabled");
        $("#editForm [name='ityWhiId']").attr("disabled", "disabled");
        $("#editForm [name='ityBookkeepingDateText']").attr("disabled", "disabled");
        $("#editForm [name='ityRemark']").attr("disabled", "disabled");
        $("#editForm [name='ityRemarkType']").attr("disabled","disabled");
        $("#editForm [name='ityCaseNo']").attr("disabled","disabled");
        js.modal.open("modal-select-purchase");
    }


    /**
     *@FunctionName: findWarehouseList
     *@Description: 获取仓库列表
     *@DesignIdea: 因为此页面是外购件页面，所以获取外购件仓库列表。
     *@Author: 徐一贺
     *@CreateDate: 2020/5/9 16:10
     *@Phone: 18241927380
     *@Param: []
     *@Version: v 1.0.0
     */
    function findWarehouseList() {
        js.ajax({
            url: ctx + 'common/warehouseInfo/list',
            type: 'post',
            traditional: true,            // 阻止深度序列化， 使参数可以使用数组
            dataType: 'json',
            contentType: "application/x-www-form-urlencoded",
            data: {},
            async: true,                // 异步执行
            success: function (result) {
                if (result.type === web_status.SUCCESS) {
                    $('#ityWhiId').empty();
                    $("#editForm [name='ityWhiId']").empty();

                    $('#ityWhiId').append('<option selected="selected" style="vertical-align: middle;text-align: center" value="">全部</option>');
                    for (var i = 0; i < result.data.rows.length; i++) {
                        $('#ityWhiId').append('<option style="vertical-align: middle;text-align: center" value="' + result.data.rows[i].whiId + '">' + result.data.rows[i].whiName + '</option>');
                        $("#editForm [name='ityWhiId']").append('<option style="vertical-align: middle;text-align: center" value="' + result.data.rows[i].whiId + '">' + result.data.rows[i].whiName + '</option>');
                    }
                } else {
                    js.modal.warning(result.msg);
                }
            },
            error: function () {
                js.modal.fail();
            }
        })
    }


    /**
     *@FunctionName: findDeptList
     *@Description: 获取部门列表
     *@DesignIdea: 获取部门列表
     *@Author: 徐一贺
     *@CreateDate: 2020/5/9 16:10
     *@Phone: 18241927380
     *@Param: []
     *@Version: v 1.0.0
     */
    function findDeptList() {
        js.post({
            url: ctx + "purWarOutManage/findDeptList",
            data: {},
            contentType: "application/json",
            success: function (result) {
                if (result.type == 'SUCCESS') {
                    var list = result.data;
                    $('#odrTakeTeam').empty();
                    for (var i = 0; i < list.length; i++) {
                        $('#odrTakeTeam').append('<option value="' + list[i].depName + '">' + list[i].depName + '</option>');
                    }
                }
            }
        });
    }

    /**
     *@FunctionName: displayMoney
     *@Description: 权限判定，有查看金额权限才能看到金额单价等信息，否则只能查看***。
     *@DesignIdea: 有权看钱，无权看星，规范管理，守护秘密。
     *@Author: 徐一贺
     *@CreateDate: 2020/5/9 16:10
     *@Phone: 18241927380
     *@Param: [value] 有权才能看到的值
     *@Version: v 1.0.0
     */
    function displayMoney(value) {
        if (hasP('purinv:amount:view')) {
            if (value == undefined || value == null) {
                return "--";
            }
            return value;
        } else {
            return '***';
        }
    }

    var ids = [];
    var statusText = ["无状态", "执行中", "未开始", "暂缓", "已完成", "取消"];

    /**
     *@FunctionName: selectAll
     *@Description: 全选控制方法。
     *@DesignIdea: 利用jquery赋复选框的prop方法判断其值是否为真或假来控制全选和全不选。
     *@Author: 徐一贺
     *@CreateDate: 2020/5/9 16:10
     *@Phone: 18241927380
     *@Param: [obj] 判定全选状态的控件
     *@Version: v 1.0.0
     */
    function selectAll(obj) {
        if ($(obj).prop("checked")) {
            $('input[name="cb_inventory"]').prop("checked", true);
        }
        if ($(obj).prop("checked") == false) {
            $('input[name="cb_inventory"]').prop("checked", false);
        }
    }

    /**
     *@Description: 跳转到台账页面
     */
    function gotoLedger(ityId) {
        location.href = ctx + "pInventoryInfoEdit/gotoLedger/" + ityId;
    }

    $(function () {
        $("title").html($("title").html()+" —— 外购件库存信息编辑");
        // $(window).resize(function () {
        //     var h = $(window).height();
        //     var w = $(window).width();
        //     var $fixedTableBody = $("#inventoryQueryTable").closest("div"),
        //         $fixedTableBodyColumns = $fixedTableBody.prev(),
        //         $FixedtableContainer = $fixedTableBody.closest("div");
        //     $FixedtableContainer.height(h - 200);
        //     $fixedTableBodyColumns.height(h - 253);
        // });

        /**
         *@FunctionName:  $("#btn-editItems").on('click', function () { });
         *@Description: 批量修改。
         *@DesignIdea: 对选中的库存信息进行批量修改，如果未修改则进行提示。
         *@Author: 徐一贺
         *@CreateDate: 2020/5/9 16:10
         *@Phone: 18241927380
         *@Param: [click] 按钮单击事件，[function（）{}] 执行的函数
         *@Version: v 1.0.0
         */
        $("#btn-editItems").on('click', function () {
            var ityIds = "";
            $('input[name="cb_inventory"]').each(function (index, data) {
                if ($(this).prop("checked")) {
                    ityIds += $(this).attr("data") + ",";
                }
            });
            ityIds = ityIds.substring(0, ityIds.length - 1);
            if (ityIds == "") {
                js.modal.alert("请选择要修改的数据！");
                return
            }
            openEditPanel(ityIds);
        });

        /**
         *@FunctionName:  $("#btn-submit").on('click', function () { });
         *@Description: 提交修改。
         *@DesignIdea: 提交修改内容。
         *@Author: 徐一贺
         *@CreateDate: 2020/5/9 16:10
         *@Phone: 18241927380
         *@Param: [click] 按钮单击事件，[function（）{}] 执行的函数
         *@Version: v 1.0.0
         */
        $("#btn-submit").on('click', function () {
            var ityProName = $("#editForm [name='ityProName']");
            var ityPosition = $("#editForm [name='ityPosition']");
            var ityWhiId = $("#editForm [name='ityWhiId']");
            var ityBookkeepingDateText = $("#editForm [name='ityBookkeepingDateText']");
            var ityRemark = $("#editForm [name='ityRemark']");
            var ityRemarkType = $("#editForm [name='ityRemarkType']");
            var ityCaseNo = $("#editForm [name='ityCaseNo']");
            if (ityProName.attr("disabled") === 'disabled' &&
                ityPosition.attr("disabled") === 'disabled' &&
                ityWhiId.attr("disabled") === 'disabled' &&
                ityCaseNo.attr("disabled") === 'disabled' &&
                ityBookkeepingDateText.attr("disabled") === 'disabled' &&
                ityRemark.attr("disabled") === 'disabled' &&
                ityRemarkType.attr("disabled") === 'disabled'){
                js.modal.warning("请勾选启用要修改的项。");
                return;
            }
            js.post(
                {
                    url: ctx + 'pInventoryInfoEdit/getPInventoryList',
                    data: {
                        ityIds: $("#editForm [name='ityIds']").val()
                    },
                    success: function (result) {
                        for (var i = 0; i < result.data.length; i++) {
                            if(ityProName.attr("disabled") !== 'disabled'){
                                if (result.data[i].ityStockType === 2 && $("#editForm [name='ityProName']").val().trim() === "") {
                                    js.modal.warning("项目在库的库存信息项目名称不可为空！");
                                    return false;
                                }
                            }
                        }
                        js.post(
                            {
                                url: ctx + 'pInventoryInfoEdit/save',
                                data: $("#editForm").serialize(),
                                success: function (result) {
                                    js.modal.hide("modal-select-purchase");
                                    js.table.refresh(bTable);
                                },
                                dataType: 'json'
                            }
                        );
                    },
                    dataType: 'json'
                }
            );
        })

        //加载仓库列表
        findWarehouseList();
        //加载部门列表
        findDeptList();
        /**
         *@FunctionName:  js.table.init({}）
         *@Description: 加载库存列表。
         *@DesignIdea: 依据ID值为[queryForm]的form标签中的控件为检索条件来加载库存列表。
         *@Author: 徐一贺
         *@CreateDate: 2020/5/9 16:10
         *@Phone: 18241927380
         *@Param: 列表初始化所使用的参数较多，需自行查看bootstarpTable文档。
         *@Version: v 1.0.0
         */
        bTable = js.table.init({
            id: 'inventoryQueryTable',
            url: ctx + "pInventoryInfoEdit/inventoryList",
            showColumns: true,
            showExport: false,
            showFullscreen: true,
            pageSize: 300,
            uniqueId: "ityId",
            onLoadSuccess: function () {
                $("#btn_inventorySearch").prop('disabled', false).removeClass('disabled');
                // $('#inventoryQueryTable thead').css("");
                $('#inventoryQueryTable thead th').each(function () {
                    $(this).width(Math.floor($(this).width()));
                });
                $('#inventoryQueryTable tbody tr:first td').each(function () {
                    $(this).width(Math.floor($(this).width()));
                });
            },
            columns: [
                {
                    title: '<input title="全选" onclick="selectAll(this)" type="checkbox" />',
                    width: '30',
                    field: 'ityDataStatus',
                    formatter: function (value, row, index) {
                        var ityDataStatus = "";
                        if (value == 2) {
                            ityDataStatus = 'disabled';
                        } else {
                            ityDataStatus = '';
                        }
                        ids.push('cb_inventory_' + row.ityId);
                        return '<input ' + ityDataStatus + ' id="' + 'cb_inventory_' + row.ityId + '" name="cb_inventory" data="' + row.ityId + '"  type="checkbox" />';
                    }
                },
                {
                    title: '序号', field: 'ityId', width: '50',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {title: 'SAP物料编码', field: 'itySapCode', width: '120'},
                {title: '物料描述', field: 'ityMatDesc', width: '200'},
                {title: '数量', field: 'ityNum'},
                {title: '单位', field: 'ityNumUnit'},
                {
                    title: '单价', field: 'ityPrice', formatter: function (value, row, index) {
                        return displayMoney(value);
                    }
                },
                {
                    title: '项目编号', field: 'ityProCode', formatter: function (value, row, index) {
                        if (value == undefined || value == null) {
                            value = "--";
                        }
                        return value;
                    }
                },
                {
                    title: '项目名称', field: 'ityProName', width: '200', formatter: function (value, row, index) {
                        if (value == undefined || value == null) {
                            value = "--";
                        }
                        return value;
                    }
                },
                {
                    title: '生产状态', field: 'proProductionStatus',
                    formatter: function (value, row, index) {
                        if (value == undefined || value == null) {
                            value = 0;
                        }
                        return statusText[value];
                    }
                },
                {title: '跟踪号', field: 'ityTrackCode'},
                {
                    title: '备注', field: 'ityRemark',
                    formatter: function (value, row, index) {
                        if (value == undefined || value == null) {
                            return "";
                        }
                        return value;
                    }
                },
                {title: '仓库', field: 'whiName'},
                {title: '区位', field: 'ityPosition'},
                {title: '箱号', field: 'ityCaseNo'},
                {
                    title: '在库类型', field: 'ityStockType',
                    formatter: function (value, row, index) {
                        if(value==1){
                            return "库存在库";
                        }else if(value==2){
                            return "项目在库";
                        }
                    }
                },
                {title: '记账日期', field: 'ityBookkeepingDate', width: '100'},
                {
                    title: '操作', field: 'ityId', width: '160',
                    formatter: function (value, row, index) {
                        if (hasP("purinv:purinvedit:edit")) {
                            var html = '<button type="button"  class="btn btn-warning btn-xs" onclick="openEditPanel(' + row.ityId + ')">编辑</button>';
                            if (hasP('purinv:purledgeredit:view')) {
                                html += '<button type="button" class="btn btn-info btn-xs" onclick="gotoLedger(' + value + ')">台账</button>';
                            }
                            return html;
                        }
                        return "";

                    }
                }
            ]
        });
        /**
         *@FunctionName:  js.table.init({}）
         *@Description: 库存列表搜索。
         *@DesignIdea: 依据ID值为[queryForm]的form标签中的控件为检索条件来重新加载库存列表。
         *@Author: 徐一贺
         *@CreateDate: 2020/5/9 16:10
         *@Phone: 18241927380
         *@Param: [click] 按钮单击事件，[function（）{}] 执行的函数
         *@Version: v 1.0.0
         */
        $("#btn_inventorySearch").on('click', function () {
            $("#btn_inventorySearch").prop('disabled', true).addClass('disabled');
            js.table.search(bTable);
        });
    });
</script>
</body>
</html>
